package com.shenglaotuan.community.article.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.shenglaotuan.community.tag.entity.Tag;
import com.shenglaotuan.community.tag.mapper.TagMapper;
import com.shenglaotuan.community.user.entity.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author ruidong
 * @since 2020-08-22
 */
@Data
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
@NoArgsConstructor
public class ArticleVO implements Serializable {

    private static final long serialVersionUID = 1L;

    private String id; // 文章id

    private User user; // 用户

    private String title; // 文章标题

    private String content; // 文章 md 内容

    private String contentHtml; // 文章 html 内容
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date gmtCreated; // 创建时间

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
    private Date gmtModified; // 修改时间

    private List<Tag> tags; // 文章标签


    public void findTags(TagMapper tagMapper) {
        this.tags = tagMapper.listArticleTags(this.id);
    }
}
